package com.gw.vip.server.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gw.vip.server.po.Trans;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author GW
 * @description
 * @since 2022-05-04
 */
public interface TransMapper extends BaseMapper<Trans> {
    /**
     * 设置清算日期
     * @param clearDate
     * @param clearMaxTime
     */
    @Update("UPDATE trans SET clear_date = #{clearDate} WHERE complete_time < #{clearMaxTime} AND status!='T' AND order_type IN (SELECT ID FROM sys_order_type WHERE clear_flag='1')")
    void setClearDate(LocalDate clearDate, LocalDateTime clearMaxTime);

    /**
     * 根据orderId获取订单信息
     * @param orderId
     * @return
     */
    @Select("SELECT * FROM trans WHERE order_id=#{orderId}")
    List<Trans> listByOrderId(String orderId);

    /**
     * 根据clientTransId获取订单
     * @param clientTransId
     * @return
     */
    @Select("SELECT * FROM trans WHERE client_trans_id = #{clientTransId}")
    Trans getByBase(String clientTransId);
}
